#include "Projectile.h"

Vec3 max = Vec3(0.0f,0.0f,-15.0f);
Projectile::Projectile(Matrix m):
     Transform(m),bullet(new Primitive(SPHERE,1.5f,10.0f)),dir(Vec3(0.0f,0.0f,-0.2f)),max(Vec3(0.0f,0.0f,-14.0f))
{
     SceneObject::addChild(bullet);
}

Projectile::Projectile(Matrix m, Vec3 d):
     Transform(m),bullet(new Primitive(SPHERE,1.5f,100.0f)), dir(d),max(Vec3(0.0f,0.0f,-14.0f))
{
     SceneObject::addChild(bullet);
}

Projectile::~Projectile(){}

void Projectile::update(float timeElapsed){
     Transform::update(timeElapsed);
}
void Projectile::postRender(float timeElapsed){
     Transform::postRender(timeElapsed);
}

void Projectile::render(float timeElapsed){
     std::cout << "Render [" << "Projectile" << "] scene object " << std::endl; 
     std::cout << "matrix [" <<matrix.getTrans()<< ":" <<max<< "] max " << std::endl; 
     if(matrix.getTrans()[2] > max[2]){
          matrix.setTrans(matrix.getTrans()+dir);
     }
     float modelview[16];
     glGetFloatv(GL_MODELVIEW_MATRIX , modelview);
     for (int i=0;i<16;i++){
         //std::cout<< i<<":" << modelview[i] << std::endl; 
     }   
     pos=Vec3(modelview[12],modelview[13],modelview[14]); 
     
     Transform::render(timeElapsed);
}                 
